package com.qf2210.group.three.server.config;


import com.qf2210.group.three.utils.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class MyAnnoExceptionResolver {
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public JsonResult resolverJson(Exception ex){
        JsonResult jsonResult=new JsonResult();
        jsonResult.setData("发生异常");
        jsonResult.setErrorCode(500);
        jsonResult.setErrorMessage(ex.getMessage());
        return jsonResult;
    }

}